<template>
    <div style="min-width: 829px">
        <div v-if="$route.path == '/inReport'">
            <div class="vs-search-box">
                <el-tabs v-search-box-enter v-model="active" @tab-click="handleClick">
                    <el-tab-pane label="毛坯" name="0">
                        <el-form ref="form" :inline="true" :model="paging" label-width="110px">
                            <el-form-item label="商品类型：">
                                <el-select style="width: 150px" clearable v-model="paging.roughcast_type"
                                    placeholder="请选择">
                                    <el-option label="标准毛坯" value="1"> </el-option>
                                    <el-option label="定制毛坯" value="2"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="入库类型：">
                                <el-select style="width: 150px" clearable v-model="paging.in_type" placeholder="请选择">
                                    <el-option label="要货入库" value="1"> </el-option>
                                    <el-option label="门店调拨" value="2"> </el-option>
                                    <el-option label="积分商城入库" value="3"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="商品系列：">
                                <el-input v-model="paging.goods_name" style="width: 200px" placeholder="请输入商品系列"
                                    clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="商品编码：">
                                <el-input v-model="paging.number" style="width: 200px" placeholder="请输入商品编码" clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="" class="vs-right-btns">
                                <el-button @click="reset">重置</el-button>
                                <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                            </el-form-item>
                            <el-form-item label="毛坯种类：">
                                <el-select style="width: 150px" clearable v-model="paging.roughcast" placeholder="请选择">
                                    <el-option v-for="item in options.blank_type" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="递针类型：">
                                <el-select style="width: 150px" clearable v-model="paging.needle" placeholder="请选择">
                                    <el-option v-for="item in options.needle_type" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="尺寸：">
                                <el-select style="width: 150px" clearable v-model="paging.size" placeholder="请选择">
                                    <el-option v-for="item in options.size" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="长度：">
                                <el-select style="width: 150px" clearable v-model="paging.length" placeholder="请选择">
                                    <el-option v-for="item in options.length" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="性别：">
                                <el-select style="width: 150px" clearable v-model="paging.sex" placeholder="请选择">
                                    <el-option v-for="item in options.sex" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="颜色：">
                                <el-select style="width: 150px" clearable v-model="paging.colour" placeholder="请选择">
                                    <el-option v-for="item in options.colour" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="查询时间段：">
                                <el-date-picker v-model="bill_time_start" type="daterange" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"
                                    style="width: 300px"> </el-date-picker>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane label="定制成品" name="1">
                        <el-form ref="form" :inline="true" :model="paging" label-width="110px">
                            <el-form-item label="入库类型：">
                                <el-select style="width: 150px" clearable v-model="paging.in_type" placeholder="请选择">
                                    <el-option label="要货入库" value="1"> </el-option>
                                    <el-option label="门店调拨" value="2"> </el-option>
                                    <el-option label="积分商城入库" value="3"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="商品系列：">
                                <el-input v-model="paging.goods_name" style="width: 200px" placeholder="请输入商品系列"
                                    clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="商品编码：">
                                <el-input v-model="paging.number" style="width: 200px" placeholder="请输入商品编码" clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="" class="vs-right-btns">
                                <el-button @click="reset">重置</el-button>
                                <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                            </el-form-item>
                            <el-form-item label="毛坯种类：">
                                <el-select style="width: 150px" clearable v-model="paging.roughcast" placeholder="请选择">
                                    <el-option v-for="item in options.blank_type" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="递针类型：">
                                <el-select style="width: 150px" clearable v-model="paging.needle" placeholder="请选择">
                                    <el-option v-for="item in options.needle_type" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="尺寸：">
                                <el-select style="width: 150px" clearable v-model="paging.size" placeholder="请选择">
                                    <el-option v-for="item in options.size" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="长度：">
                                <el-select style="width: 150px" clearable v-model="paging.length" placeholder="请选择">
                                    <el-option v-for="item in options.length" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="性别：">
                                <el-select style="width: 150px" clearable v-model="paging.sex" placeholder="请选择">
                                    <el-option v-for="item in options.sex" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="颜色：">
                                <el-select style="width: 150px" clearable v-model="paging.colour" placeholder="请选择">
                                    <el-option v-for="item in options.colour" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="查询时间段：">
                                <el-date-picker v-model="bill_time_start" type="daterange" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"
                                    style="width: 300px"> </el-date-picker>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane label="标准成品" name="5">
                        <el-form ref="form" :inline="true" :model="paging" label-width="110px">
                            <el-form-item label="入库类型：">
                                <el-select style="width: 150px" clearable v-model="paging.in_type" placeholder="请选择">
                                    <el-option label="要货入库" value="1"> </el-option>
                                    <el-option label="门店调拨" value="2"> </el-option>
                                    <el-option label="积分商城入库" value="3"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="商品系列：">
                                <el-input v-model="paging.goods_name" style="width: 200px" placeholder="请输入商品系列"
                                    clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="商品编码：">
                                <el-input v-model="paging.number" style="width: 200px" placeholder="请输入商品编码" clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="标准成品类型：" prop="sex_type">
                                <el-select style="width: 200px" v-model="paging.sex_type" @change="styleChange"
                                    placeholder="请选择">
                                    <el-option label="男款" :value="353"> </el-option>
                                    <el-option label="女款" :value="354"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="" class="vs-right-btns">
                                <el-button @click="reset">重置</el-button>
                                <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                            </el-form-item>
                            <el-form-item label="款号：" prop="item">
                                <el-select style="width: 200px" clearable v-model="paging.item" placeholder="请选择">
                                    <el-option v-for="item in options.item" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="毛坯种类：" prop="roughcast">
                                <el-select style="width: 200px" clearable v-model="paging.roughcast" placeholder="请选择">
                                    <el-option v-for="item in options.roughcast" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="颜色：" prop="colour">
                                <el-select style="width: 200px" clearable v-model="paging.colour" placeholder="请选择">
                                    <el-option v-for="item in options.colour" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="尺寸：" prop="size">
                                <el-select style="width: 200px" clearable v-model="paging.size" placeholder="请选择">
                                    <el-option v-for="item in options.size" :key="item.id" :label="item.title"
                                        :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="查询时间段：">
                                <el-date-picker v-model="bill_time_start" type="daterange" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"
                                    style="width: 300px"> </el-date-picker>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane label="积分商品" name="2">
                        <el-form ref="form" :inline="true" :model="paging" label-width="110px">
                            <el-form-item label="入库类型：">
                                <el-select style="width: 150px" clearable v-model="paging.in_type" placeholder="请选择">
                                    <el-option label="要货入库" value="1"> </el-option>
                                    <el-option label="门店调拨" value="2"> </el-option>
                                    <el-option label="积分商城入库" value="3"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="商品系列：">
                                <el-input v-model="paging.goods_name" style="width: 200px" placeholder="请输入商品系列"
                                    clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="商品编码：">
                                <el-input v-model="paging.number" style="width: 200px" placeholder="请输入商品编码" clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="查询时间段：">
                                <el-date-picker v-model="bill_time_start" type="daterange" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"
                                    style="width: 300px"> </el-date-picker>
                            </el-form-item>
                            <el-form-item label="" class="vs-right-btns">
                                <el-button @click="reset">重置</el-button>
                                <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane label="洗护用品" name="3">
                        <el-form ref="form" :inline="true" :model="paging" label-width="110px">
                            <el-form-item label="入库类型：">
                                <el-select style="width: 150px" clearable v-model="paging.in_type" placeholder="请选择">
                                    <el-option label="要货入库" value="1"> </el-option>
                                    <el-option label="门店调拨" value="2"> </el-option>
                                    <el-option label="积分商城入库" value="3"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="商品系列：">
                                <el-input v-model="paging.goods_name" style="width: 200px" placeholder="请输入商品系列"
                                    clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="商品编码：">
                                <el-input v-model="paging.number" style="width: 200px" placeholder="请输入商品编码" clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="查询时间段：">
                                <el-date-picker v-model="bill_time_start" type="daterange" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"
                                    style="width: 300px"> </el-date-picker>
                            </el-form-item>
                            <el-form-item label="" class="vs-right-btns">
                                <el-button @click="reset">重置</el-button>
                                <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane label="其他" name="4">
                        <el-form ref="form" :inline="true" :model="paging" label-width="110px">
                            <el-form-item label="入库类型：">
                                <el-select style="width: 150px" clearable v-model="paging.in_type" placeholder="请选择">
                                    <el-option label="要货入库" value="1"> </el-option>
                                    <el-option label="门店调拨" value="2"> </el-option>
                                    <el-option label="积分商城入库" value="3"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="商品系列：">
                                <el-input v-model="paging.goods_name" style="width: 200px" placeholder="请输入商品系列"
                                    clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="商品编码：">
                                <el-input v-model="paging.number" style="width: 200px" placeholder="请输入商品编码" clearable>
                                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                                </el-input>
                            </el-form-item>
                            <el-form-item label="查询时间段：">
                                <el-date-picker v-model="bill_time_start" type="daterange" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"
                                    style="width: 300px"> </el-date-picker>
                            </el-form-item>
                            <el-form-item label="" class="vs-right-btns">
                                <el-button @click="reset">重置</el-button>
                                <el-button @click="handleCurrentChange(1)" type="primary">查询</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                </el-tabs>
            </div>
            <div class="vs-table-box">
                <div class="operation-box clear-float">
                    <el-button v-if="utils.getIsShopowner()" style="margin-left: auto" icon="el-icon-download"
                        type="primary" @click="exportFn">导出</el-button>
                </div>
                <el-table @sort-change="sortChange" v-loading="loading" :data="tableData"
                    header-row-class-name="has-gutter-table" style="width: 100%" border :key="active"
                    v-if="active == 0 || active == 1" show-summary :summary-method="getSummaries">
                    <!-- <el-table-column type="selection" width="55" align="center"> </el-table-column> -->
                    <el-table-column prop="id" label="序号" align="center"></el-table-column>
                    <el-table-column prop="number" label="入库单号" align="center"></el-table-column>
                    <el-table-column label="商品分类" align="center">
                        <template slot-scope="scope">
                            <div v-if="active == 0">{{
                                scope.row.roughcast_type == 1 ? '标准毛坯' : scope.row.roughcast_type
                                    == 2 ? '定制毛坯' : ''
                            }}</div>
                            <div v-else>{{
                                scope.row.roughcast_type == 1 ? '标准成品' : scope.row.roughcast_type == 2 ?
                                    '定制成品' : ''
                            }}</div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="goods_number" label="商品编码" align="center"></el-table-column>
                    <el-table-column prop="goods_name" label="商品系列" align="center"></el-table-column>
                    <el-table-column prop="roughcast" label="毛坯种类" align="center"></el-table-column>
                    <el-table-column prop="needle" label="递针类型" align="center"></el-table-column>
                    <el-table-column prop="size" label="尺寸" align="center"></el-table-column>
                    <el-table-column prop="sex" label="性别" align="center"></el-table-column>
                    <el-table-column prop="length" label="长度" align="center"></el-table-column>
                    <el-table-column prop="colour" label="颜色" align="center"></el-table-column>
                    <el-table-column prop="count" label="数量" align="center"></el-table-column>
                    <el-table-column prop="price" label="单价" align="center"></el-table-column>
                    <el-table-column prop="total" label="总价" align="center"> </el-table-column>
                    <el-table-column prop="out_trade_no" label="入库类型" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.type | typeFilters }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="out_trade_no" label="日期" align="center" sortable>
                        <template slot-scope="scope">
                            {{ $moment(scope.row.create_time * 1000).format('YYYY-MM-DD') }}
                        </template>
                    </el-table-column>
                </el-table>
                <el-table @sort-change="sortChange" v-loading="loading" :data="tableData"
                    header-row-class-name="has-gutter-table" style="width: 100%" border :key="active + 2"
                    v-else-if="active == 5" show-summary :summary-method="getSummaries">
                    <!-- <el-table-column type="selection" width="55" align="center"> </el-table-column> -->
                    <el-table-column prop="id" label="序号" align="center"></el-table-column>
                    <el-table-column prop="number" label="入库单号" align="center"></el-table-column>
                    <el-table-column prop="goods_number" label="商品编码" align="center"></el-table-column>
                    <el-table-column prop="goods_name" label="商品系列" align="center"></el-table-column>
                    <el-table-column prop="sex_type" label="标准成品类型" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.sex_type == 353 ? '男款' : scope.row.roughcast_type == 354 ? '女款' : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="roughcast" label="毛坯种类" align="center"></el-table-column>
                    <el-table-column prop="item" label="款号" align="center"></el-table-column>
                    <el-table-column prop="size" label="尺寸" align="center"></el-table-column>
                    <el-table-column prop="colour" label="颜色" align="center"></el-table-column>
                    <el-table-column prop="count" label="数量" align="center"></el-table-column>
                    <el-table-column prop="price" label="单价" align="center"></el-table-column>
                    <el-table-column prop="total" label="总价" align="center"> </el-table-column>
                    <el-table-column prop="out_trade_no" label="入库类型" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.type | typeFilters }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="out_trade_no" label="日期" align="center" sortable>
                        <template slot-scope="scope">
                            {{ $moment(scope.row.create_time * 1000).format('YYYY-MM-DD') }}
                        </template>
                    </el-table-column>
                </el-table>
                <el-table v-loading="loading" :data="tableData" header-row-class-name="has-gutter-table"
                    style="width: 100%" border :key="active + 1" v-else show-summary :summary-method="getSummaries">
                    <!-- <el-table-column type="selection" width="55" align="center"> </el-table-column> -->
                    <el-table-column prop="id" label="序号" align="center"></el-table-column>
                    <el-table-column prop="number" label="入库单号" align="center"></el-table-column>
                    <el-table-column prop="goods_number" label="商品编码" align="center"></el-table-column>
                    <el-table-column prop="title" label="商品系列" align="center"></el-table-column>
                    <el-table-column prop="sku_text" label="规格" align="center"></el-table-column>
                    <el-table-column prop="unit" label="单位" align="center"></el-table-column>
                    <el-table-column prop="count" label="数量" align="center"></el-table-column>
                    <el-table-column prop="price" label="单价" align="center"></el-table-column>
                    <el-table-column prop="total" label="总价" align="center"> </el-table-column>
                    <el-table-column prop="out_trade_no" label="入库类型" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.type | typeFilters }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="out_trade_no" label="日期" align="center">
                        <template slot-scope="scope">
                            {{ $moment(scope.row.create_time * 1000).format('YYYY-MM-DD') }}
                        </template>
                    </el-table-column>
                </el-table>
                <!-- <div class="divTable">
                    <div>当前页合计：1000</div>
                    <div>总合计:10000</div>
                </div> -->
                <div class="vs-paging-box">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page.sync="paging.page" :page-size="paging.limit" :page-sizes="[100, 200, 500, 1000]"
                        layout="total, sizes, prev, pager, next, jumper" :total="paging.total"> </el-pagination>
                </div>
            </div>
        </div>
        <router-view></router-view>
    </div>
</template>

<script>
export default {
    data() {
        return {
            loading: false,
            bill_time_start: [],
            paging: {
                page: 1,
                total: 0,
                limit: 100,
                roughcast_type: '',
                goods_name: '',
                number: '',
                // stock: 0,
                // early_warning_count: 0,
                roughcast: '',
                needle: '',
                size: '',
                length: '',
                colour: '',
                sex: '',
                in_type: '',
                store_id: JSON.parse(localStorage.getItem('userInfo')).store_id,
                item: '',
                sex_type: '',
            },
            tableData: [],
            active: 0,
            options: {
                blank_type: [],
                needle_type: [],
                size: [],
                length: [],
                sex: [],
                colour: [],
                roughcast: [],
                item: [],
            },
        };
    },
    filters: {
        typeFilters(val) {
            let arr = ['', '要货入库', '门店调拨', '积分商城入库'];
            return arr[val];
        },
    },
    created() {
        if (this.$route.path == '/inReport') {
            this.handleCurrentChange(1);
            this.getGoodsCategory();
        }
    },
    methods: {
        styleChange() {
            this.getGoodsCategoryCheng2();
        },
        async getGoodsCategoryCheng2() {
            //查询标准成品分类类型
            let { code, data } = await this.$Http.getGoodsCategoryCheng({ sex_type: this.paging.sex_type });
            if (code) {
                let { size, colour, roughcast, item } = data;
                this.options = { size, roughcast, item, colour };
            }
        },
        sortChange(column) {
            if (column.order == 'ascending') {
                this.paging.order = column.prop + ' asc';
            } else if (column.order == 'descending') {
                this.paging.order = column.prop + ' desc';
            } else {
                this.paging.order = '';
            }
            this.handleCurrentChange(1);
            this.getGoodsCategory();
        },
        // 导出
        async exportFn() {
            if (!this.bill_time_start) {
                this.bill_time_start = [];
            }
            this.paging.type = this.active * 1 + 1;
            this.paging.start_time = this.bill_time_start[0] || '';
            this.paging.end_time = this.bill_time_start[1] || '';
            let obj = Object.assign({}, this.paging);

            let url = this.utils.data.baseURL + 'store/stock/storeInstockReportExport';
            this.utils.urlToBlob(url, '入库报表', obj);
        },
        // 获取分类
        async getGoodsCategory() {
            this.options.blank_type = this.options.needle_type = this.options.size = this.options.length = this.options.sex = this.options.colour = this.options.roughcast = this.options.item = [];
            if (this.active != 5) {
                let active = '';
                if (this.active == 0) {
                    active = 1;
                } else {
                    active = 2;
                }
                let { code, data } = await this.$Http.getGoodsCategoryList({ special_type: active });
                if (code) {
                    let { blank_type, needle_type, size, length, sex, colour } = data;
                    this.options = { blank_type, needle_type, size, length, sex, colour };
                }
            } else {
                this.getGoodsCategoryCheng2();
            }
        },
        handleClick(tab, event) {
            this.reset();
            if (this.active == 0 || this.active == 1 || this.active == 5) {
                this.getGoodsCategory();
            }
        },
        async repairGetList() {
            if (!this.bill_time_start) {
                this.bill_time_start = [];
            }
            this.paging.type = this.active * 1 + 1;
            this.paging.start_time = this.bill_time_start[0] || '';
            this.paging.end_time = this.bill_time_start[1] || '';
            let obj = Object.assign({}, this.paging);
            this.loading = true;
            let { code, data } = await this.$Http.instockReport(obj);
            this.loading = false;
            if (code) {
                console.log(1);
                this.tableData = data.data;
                this.paging.total = data.total;
                for (let o of this.tableData) {
                    this.$set(o, 'total', (o.price * o.count).toFixed(2));
                }
            }
        },
        reset() {
            //重置
            this.paging = this.$options.data().paging;
            this.handleCurrentChange(1);
        },
        handleSizeChange(val) {
            this.paging.limit = val;
            this.repairGetList();
        },
        handleCurrentChange(val) {
            this.paging.page = val;
            this.repairGetList();
        },
        getSummaries(param) {
            const { columns, data } = param;
            const sums = [];
            columns.forEach((column, index) => {
                if (index == 0) {
                    sums[index] = '合计';
                    return;
                }
                const values = data.map((item) => Number(item[column.property]));
                if (column.property == 'total') {
                    sums[index] = values.reduce((prev, curr) => {
                        const value = Number(curr);
                        if (!isNaN(value)) {
                            return prev + curr;
                        } else {
                            return prev;
                        }
                    }, 0);
                    sums[index] = sums[index].toFixed(2);
                } else if (column.property == 'count') {
                    sums[index] = values.reduce((prev, curr) => {
                        const value = Number(curr);
                        if (!isNaN(value)) {
                            return prev + curr;
                        } else {
                            return prev;
                        }
                    }, 0);
                } else {
                    sums[index] = '';
                }
            });
            return sums;
        },
    },
};
</script>

<style lang="scss" scoped>
.image-thumbnail {
    width: 130px;
    height: 130px;
}

.divTable {
    width: 100%;

    div {
        border-bottom: 1px solid #ebeef5;
        border-left: 1px solid #ebeef5;
        border-right: 1px solid #ebeef5;
        height: 50px;
        line-height: 50px;
        padding-left: 30px;
    }
}
</style>
